<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/common_setting_unit.php");         // 引入通用的设置文件 ?>
<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/module/head.php"); // 引入通用的头部 ?>
<?php include_once("../controller/data_static.php");                     // 当前页面的控制器 ?>



<body>
<!--顶部栏-->
<div id="topbar"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/controller/common/module/topbar.php'; ?></div>

<!--容器-->
<div id="container" class="<? echo $now_extender ?>">

    <!--侧边栏-->
    <div id="sidebar"><?php include $_SERVER['DOCUMENT_ROOT'] . '/controller/common/module/sidebar.php'; ?></div>


    <div id="content">
        <?php $page_title='订单产品明细统计';?>
        <?php include ROOT_PATH_.'/controlbase/module/mod-page-title.php'; ?>





<div class="detail-box  layui-form">

<div class="detail-boxes">
    <blockquote class="layui-elem-quote">
        1.由于未有多产品系统，统计必须从周一算起。<br/>
        2.退订以退钱当天计算不配送<br/>
        3.配送从下订单当天开始计算。
        4.配送按照T1规格计算，配送从下单时间+1天计算
    </blockquote>



    <form action="order_product_static.php" >


        <div class="layui-form-item search-period" style="float:left; margin-right: 15px" >
            <label class="layui-form-label">时间段</label>

            <div class="layui-input-block">
                <input type="text" name="indate" id="date" autocomplete="off"
                       class="layui-input laydate_date"
                       style="width: 300px;"
                       value="<?echo $indate?>" >
            </div>


        </div>


        <input type="hidden" name="now_extender" value="<?echo $_REQUEST['now_extender']?>">

        <button class="layui-btn  layui-btn-sm" ><i class="layui-icon">&#xe615;</i> 查找</button>
        <a class="layui-btn white layui-btn-sm" href="data_list.php?now_extender=<?echo $_REQUEST['now_extender']?>" ><i class="layui-icon">&#x1006;</i> 重置</a>
        <a class="layui-btn white layui-btn-sm" href="export_product_detail.php?indate=<?echo $indate?>&now_extender=<?echo $_REQUEST['now_extender']?>" ><i class="layui-icon">&#xe62d;</i> 导出</a>

        <br class="clearfloat"/>
    </form>


</div>



 <hr/>





<!--    列出不同学校，不同班级的统计，然后有个导出-->
<table  class="layui-table">
    <thead>

    </thead>
    <tbody>




<?foreach ($school_list as $k=>$v){?>
    <tr><td  colspan="10" style="text-align: center"><h1><?echo $v['name']?></h1></td></tr>
    <tr><td  colspan="10" style="text-align: right">日期 : <?echo $indate?>
<!--            至-->
<!--            --><?////$indate 日期+5日
//                $indate_ = strtotime($indate);
//                $indate_ = $indate_ + 86400*5;
//                $indate_ = date("Y-m-d",$indate_);
//                echo $indate_?><!--</h1>-->

        </td></tr>




<!--    开始循环这个学校的年级-->
    <?foreach ($v[$v['name']] as $k2=>$v2){?>
<!--        <h2><b>--><?//echo $v2['name'];?><!--</b></h2>-->

        <!--    开始循环这个年级的班-->
        <?foreach ($v2[$v2['name']] as $k3=>$v3){?>
<!--            <h3>--><?//echo $v3['name'];?><!--</h3>-->

            <tr>
                <th>序号</th>
                <th>班别</th>
                <th>姓名</th>
                <th>星期一<br/><?echo $indate?></th>
                <th>星期二 <br/> <?php echo $indate2=date('Y-m-d', strtotime($indate . ' +1 day')) ?></th>
                <th>星期三 <br/> <?php echo $indate3=date('Y-m-d', strtotime($indate . ' +2 day')) ?></th>
                <th>星期四 <br/> <?php echo $indate4=date('Y-m-d', strtotime($indate . ' +3 day')) ?></th>
                <th>星期五 <br/> <?php echo $indate5=date('Y-m-d', strtotime($indate . ' +4 day')) ?></th>
                <th>产品</th>
            </tr>


                <? $student_list = select_lines_items($table_prefix."order_info","student_name asc","student_name,add_date,order_name",
                    "student_school = '{$v['name']}' and
                              student_grade = '{$v2['name']}' and
                              student_class = '{$v3['name']}' and 
                              startdate <=  '{$indate} 00:00:00'   and
                              enddate >=  '{$indate} 00:00:00'  and 
                              add_date < '{$indate}  00:00:00' and
                              (status !='已删除' or status is null) and
                              pay_status = 1","");?>
                <? foreach ($student_list as $k4=>$v4){?>
                    <? if(substr($v4['add_date'],0,10) == $indate) {?>
<!--                        <span style="color: red"><b>--><?//echo $v4['student_name']?><!--</b></span>-->
                        <?;}else{?>
                        <tr>
                            <td><?echo $k4+1?> </td>
                            <td><b><?echo $v2['name'];?> <?echo $v3['name'];?></b></td>
                            <td ><?echo $v4['student_name']?></td>
                            <td >
                                <?//查看订奶时间，和今天比较，如果订奶时间比今天早，则显示为已配送
                                    $order_time = strtotime($v4['add_date']);
                                    if($order_time < strtotime($indate)){
                                        echo "已配送".$v4['add_date'];
                                    }
                                    else{
                                        echo "未配送";
                                    }?>
                            </td>
                            <td >纯牛奶</td>
                            <td >酸奶</td>
                            <td >纯牛奶</td>
                            <td >纯牛奶</td>
                            <td><?echo $v4['order_name'];?></td>
                        </tr>
                    <?}?>

                    <?;}?>


            <? if(!count($student_list)){?>
                <tr>
                <td colspan="10"><b><?echo $v2['name'];?> <?echo $v3['name'];?></b> 暂无订单</td>
                </tr>
                <?;}?>



            <tr>
                <td colspan="10"> 统计 ： <? echo count($student_list)?> </td>
            </tr>
            <tr>
            </tr>

        <?}?>

    <?}?>
<?}?>

    </tbody>
</table>




</div>
</div>

<!--content端點01-->
</div>
<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>


<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?> </body>
</html>
